home *** CD-ROM | disk | FTP | other *** search
-
- '' talk2boopsi.bas
- ''
- '' Simple example of Boopsi prop gadget and integer string gadget, connecting them so
- '' they update each other when the user changes their value. This has been extended
- '' to include two buttons and to indicate which has been selected.
- ''
- '' Derived from RKM example (c) Copyright 1992 Commodore-Amiga, Inc.
- ''
- DEFINT a-z
- 'REM $include intuition.bh
- 'REM $include exec.bh
- 'REM $include utility.bc
- LIBRARY OPEN "intuition.library",37
- LIBRARY OPEN "exec.library"
- mysc& = LockPubScreen(0)
- IF mysc&=0 THEN
- PRINT "Couldn't lock public screen"
- ELSE
- drawinfo&=GetScreenDrawInfo&(mysc&)
- IF drawinfo& THEN
-
-
-
- ' The attribute mapping lists
- ' This tells the prop gadget to map its PGA_Top attribute to
- ' STRINGA_LongVal when it issues an update about the change TO its PGA_Top value.
-
- DIM prop2intmap&(6)
- TAGLIST VARPTR(prop2intmap&(0)), _
- PGA_Top&, STRINGA_LongVal&, _
- TAG_END&
-
- ' This tells the string gadget to map its STRINGA_LongVal
-
- DIM int2propmap&(6)
- TAGLIST VARPTR(int2propmap&(0)), _
- STRINGA_LongVal&, PGA_Top&, _
- TAG_END&
-
- CONST PROPGADGET_ID&=1
- CONST INTGADGET_ID&=2
- CONST OKFRAMEGADGET_ID&=3
- CONST OKTEXTGADGET_ID&=4
- CONST CANCELTEXTGADGET_ID&=5
-
-
- CONST PROPGADGETWIDTH&=10
- CONST PROPGADGETHEIGHT&=80
- CONST INTGADGETHEIGHT&=18
- CONST VISIBLE&=10
- CONST TOTAL&=100
- CONST INITIALVAL&=25
- CONST MINWINDOWWIDTH&=80
- CONST MINWINDOWHEIGHT& =150 ' (PROPGADGETHEIGHT + 70)
- CONST MAXCHARS& = 5
-
- junk&=ModifyIDCMP(WINDOW(7),IDCMP_CLOSEWINDOW&+IDCMP_GADGETUP&+IDCMP_RAWKEY&)
- ' Create a new propgclass object
- DIM propgadlist&(20)
- TAGLIST VARPTR(propgadlist&(0)), _
- GA_ID&, PROPGADGET_ID&, _ ' These are defined by gadgetclass AND
- GA_Top&, PEEKB(WINDOW(7)+BorderTop) + 5, _ ' correspond TO similarly named fields in
- GA_Left&, PEEKB(WINDOW(7)+BorderLeft) + 5, _ ' the Gadget structure.
- GA_Width&, PROPGADGETWIDTH&, _
- GA_Height&, PROPGADGETHEIGHT&, _
- ICA_MAP&, VARPTR(prop2intmap&(0)), _' The prop gadget's attribute map
- _ ' The rest of this gadget's attributes are defined by propgclass.
- PGA_Total&, TOTAL&, _ ' This is the integer range of the prop gadget.
- PGA_Top&, INITIALVAL&, _ ' The initial integer value of the prop gadget.
- _
- PGA_Visible&, VISIBLE&, _ ' This determines how much of the prop gadget area is
- _ ''covered by the prop gadget's knob, or how much of
- _ ' the gadget's TOTAL range is taken up by the prop
- _ 'gadget's knob.
- PGA_NewLook&, 1&, _ ' Use new-look prop gadget imagery
- TAG_END&
-
- PropGadget& = NewObjectA&(0, SADD("propgclass"+CHR$(0)),VARPTR(propgadlist&(0)))
- IF PropGadget& THEN
-
- ' create the integer string gadget.
-
- ' The GA_Previous attribute is defined by gadgetclass and is used to
- ' wedge a new gadget into a list of gadget's linked by their
- ' Gadget.NextGadget field. When NewObject() creates this gadget,
- ' it inserts the new gadget into this list behind the GA_Previous
- ' gadget. This attribute is a pointer to the previous gadget
- ' This attribute cannot be used to link new
- ' gadgets into the gadget list of an open window or requester,
- ' use AddGlist instead
- DIM Strgadlist&(20)
- TAGLIST VARPTR(strgadlist&(0)), _
- GA_ID&, INTGADGET_ID&, _ ' Parameters for the Gadget structure
- GA_Top&, PEEKB(WINDOW(7)+BorderTop) + 5, _
- GA_Left&, PEEKB(WINDOW(7)+BorderLeft) + PROPGADGETWIDTH& + 10, _
- GA_Width&, MINWINDOWWIDTH& -( PEEKB(WINDOW(7)+BorderLeft) +PEEKB(WINDOW(7)+BorderRight) + PROPGADGETWIDTH + 15), _
- GA_Height&, INTGADGETHEIGHT&, _
- ICA_MAP&, VARPTR(int2propmap&(0)), _ ' The attribute map
- ICA_TARGET&, PropGadget&, _ ' plus the target.
- GA_Previous&, PropGadget&, _
- STRINGA_LongVal&,INITIALVAL&, _
- STRINGA_MaxChars&, MAXCHARS&, _
- TAG_END&
-
- IntegerGadget& = NewObjectA&(0,SADD( "strgclass"+CHR$(0)),VARPTR(strgadlist&(0)))
-
- IF IntegerGadget& THEN
-
- ' Now we will have a frame that will draw round our buttons
-
- TAGLIST VARPTR(strgadlist&(0)), _
- GA_ID&, OKFRAMEGADGET_ID&, _ ' Parameters for the Gadget structure
- TAG_END&
-
- OKFrameGadget& = NewObjectA&(0,SADD( "frameiclass"+CHR$(0)),VARPTR(strgadlist&(0)))
-
- ' Now lets have our OK gadget
-
- TAGLIST VARPTR(strgadlist&(0)), _
- GA_ID&, OKTEXTGADGET_ID&, _ ' Parameters for the Gadget structure
- GA_Top&, PEEKB(WINDOW(7)+BorderTop) + 5, _
- GA_Left&, PEEKB(WINDOW(7)+BorderLeft) + PROPGADGETWIDTH& + 60, _
- GA_Immediate&, 1&, _
- GA_RelVerify&, 1&, _
- GA_DrawInfo&, drawinfo&, _
- GA_Text&, "OK", _
- GA_Image&, OKFrameGadget&, _
- GA_Previous&, IntegerGadget&, _
- TAG_END&
-
- OKGadget& = NewObjectA&(0,SADD( "frbuttonclass"+CHR$(0)),VARPTR(strgadlist&(0)))
-
- ' Now lets have our Cancel gadget
-
- TAGLIST VARPTR(strgadlist&(0)), _
- GA_ID&, CANCELTEXTGADGET_ID&, _ ' Parameters for the Gadget structure
- GA_Top&, PEEKB(WINDOW(7)+BorderTop) + 35, _
- GA_Left&, PEEKB(WINDOW(7)+BorderLeft) + PROPGADGETWIDTH& + 60, _
- GA_Immediate&, 1&, _
- GA_RelVerify&, 1&, _
- GA_DrawInfo&, drawinfo&, _
- GA_Text&, "Cancel", _
- GA_Image&, OKFrameGadget&, _
- GA_Previous&, OKGadget&, _
- TAG_END&
-
- CancelGadget& = NewObjectA&(0,SADD( "frbuttonclass"+CHR$(0)),VARPTR(strgadlist&(0)))
-
- DIM temp&(4)
- ' Because the integer string gadget did NOT
- ' exist when this example created the prop
- ' gadget, it had to wait to set the
- ' ICA_TARGET of the prop gadget.
-
- TAGLIST VARPTR(temp&(0)), ICA_TARGET&, IntegerGadget&, TAG_END&
- junk&=SetGadgetAttrsA&(PropGadget&, WINDOW(7),0, VARPTR(temp&(0)))
-
- ' Now lets make the buttons nice and wide, since the defaults are rather small.
- TAGLIST VARPTR(temp&(0)), GA_WIDTH&, 100, TAG_END&
- junk&=SetGadgetAttrsA&(CancelGadget&, WINDOW(7),0, VARPTR(temp&(0)))
- junk&=SetGadgetAttrsA&(OKGadget&, WINDOW(7),0, VARPTR(temp&(0)))
-
-
- junk&= AddGList(WINDOW(7),PropGadget&,-1,-1,0) ' Add the gadgets to the
- RefreshGList propGadget&, WINDOW(7), 0, -1 ' window and display them.
- HandleEvents
- junk&=RemoveGList(WINDOW(7), PropGadget&, -1)
- DisposeObject IntegerGadget&
- END IF
- DisposeObject PropGadget&
- END IF
-
- FreeScreenDrawInfo mysc&,drawinfo&
- END IF
- UnlockPubScreen 0, mysc&
- END IF
-
- 'STOP -1
-
- SUB HandleEvents
- STATIC junk&,imsg&,g&,cl&,id,sliderval&
- SHARED integergadget&
- ' Wait for the user to click
- '$event off
- DO
- junk&= WaitPort(PEEKL(WINDOW(7)+UserPort))
- DO
- imsg& =GetMsg(PEEKL(WINDOW(7)+UserPort ))
- IF imsg& THEN
- cl&=PEEKL(imsg&+Class)
- SELECT CASE cl&
- CASE IDCMP_CLOSEWINDOW&
- PRINT "closing window"
- ReplyMsg imsg&
- EXIT SUB
- CASE IDCMP_GADGETUP&
- g&=PEEKL(imsg&+IAddress)
- id=PEEKW(g&+GadgetGadgetID)
- SELECT CASE id
- CASE OKTEXTGADGET_ID&:
- PRINT "OK selected slider set to";
- junk&=GetAttr&( STRINGA_LongVal&, IntegerGadget&,VARPTR(sliderval&))
- PRINT sliderval&
- CASE CANCELTEXTGADGET_ID&:
- PRINT "Cancelled"
- END SELECT
- EXIT SUB
- CASE REMAINDER
- ' PRINT "class:"; cl&
- END SELECT
- ReplyMsg imsg&
- END IF
- LOOP
- LOOP
- END SUB
-
-
-